<!--
 * @Description: 车主明细 ownerDetail.vue
 * @Autor: 刘诗文
 * @Date: 2021-01-13 20:02:40
 * @LastEditors: 刘诗文
 * @LastEditTime: 2021-01-13 20:44:21
-->
<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" :cols="3" :labelWidth="130" :formType="type" :isSubmitBtn="false" />
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { isFormEmpty, notifyAction, camelCaseObject, findTableItem, findFormItem } from '@/utils';

import { getProvince, getCitys, getDistrict, getRegion } from '@/api/customerRepair/customerInfo/ownerVehicleManagement';

export default {
  name: 'ownerDetailOEM',
  mixins: [dictionary],
  props: {
    type: {
      type: String
    },
    formData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.selectedData = null;
    return {
      formList: this.createFromList()
    };
  },
  mounted() {
    // 字典值查询
    this.initDictCode();
  },
  methods: {
    createFromList() {
      return [
        { type: 'INPUT', label: '销售经销商代码', fieldName: 'a1', initialValue: '', disabled: true },
        { type: 'INPUT', label: '销售经销商名称', fieldName: 'a2', initialValue: '', disabled: true },
        {
          type: 'INPUT',
          label: '客户编号',
          fieldName: 'ownerNo',
          initialValue: this.formData.ownerNo,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '客户性质',
          fieldName: 'ownerProperty',
          itemList: this.createDictList(8011),
          initialValue: this.formData.ownerProperty,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车主姓名',
          fieldName: 'ownerName',
          initialValue: this.formData.ownerName,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'gender',
          itemList: this.createDictList(8012),
          initialValue: this.formData.gender,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车主手机',
          fieldName: 'mobile',
          initialValue: this.formData.mobile,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车主电话',
          fieldName: 'phone',
          initialValue: this.formData.phone,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '微信号',
          fieldName: 'a1',
          initialValue: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '出生日期',
          fieldName: 'birthday',
          initialValue: this.formData.birthday,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '证件类型',
          fieldName: 'ctCode',
          itemList: this.createDictList('8013'),
          initialValue: this.formData.ctCode,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '证件号码',
          fieldName: 'certificateNo',
          initialValue: this.formData.certificateNo,
          disabled: true
        },

        {
          type: 'SELECT',
          label: '所在省份',
          fieldName: 'province',
          itemList: [],
          initialValue: this.formData.province,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '城市',
          fieldName: 'city',
          itemList: [],
          initialValue: this.formData.city,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '区县',
          fieldName: 'district',
          itemList: [],
          initialValue: this.formData.district,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '邮编',
          fieldName: 'zipCode',
          initialValue: this.formData.zipCode,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '联系地址',
          fieldName: 'address',
          selfCols: 3,
          initialValue: this.formData.address,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '运营单位联系人',
          fieldName: 'a3',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '运营单位电话',
          fieldName: 'a4',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '传真',
          fieldName: 'fax',
          initialValue: this.formData.fax,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '法人代表姓名',
          fieldName: 'a5',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '法人代表姓名',
          fieldName: 'a6',
          initialValue: '',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '职业',
          fieldName: 'vocationType',
          itemList: this.createDictList(8022),
          initialValue: this.formData.vocationType,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '学历',
          fieldName: 'a6',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '户口类型',
          fieldName: 'a7',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '单位性质',
          fieldName: 'a8',
          initialValue: '',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '单位性质',
          fieldName: 'industryFirst',
          itemList: this.createDictList('8251'),
          initialValue: '',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '行业类型',
          fieldName: 'industrySecond',
          itemList: this.createDictList('8252'),
          initialValue: '',
          disabled: true
        },

        {
          type: 'SELECT',
          label: '年家庭收入',
          fieldName: 'familyIncome',
          itemList: this.createDictList(1290),
          initialValue: this.formData.familyIncome,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '婚姻状况',
          fieldName: 'ownerMarriage',
          itemList: this.createDictList('8018'),
          initialValue: this.formData.ownerMarriage,
          disabled: true
        },
        {
          type: 'SELECT',
          label: '喜欢联系方式',
          fieldName: 'bestConcatType',
          itemList: this.createDictList('9123'),
          initialValue: this.formData.bestConcatType,
          disabled: true
        }
      ];
    },
    initDictCode() {
      // 获取省市
      this.getRegion();
    },
    // 获取省市
    async getRegion() {
      const allRegion = await getRegion();
      let regionList = allRegion.data.map(x => ({ value: x.regionId, text: x.regionName }));
      let targetFormItems = [findFormItem(this.formList, 'province'), findFormItem(this.formList, 'city'), findFormItem(this.formList, 'district')];
      targetFormItems.forEach(item => {
        item.itemList = regionList;
      });
    }
  }
};
</script>
<style lang="less" scoped></style>
